<?php
/**
 * Created by PhpStorm.
 * User: PGF(592472116@qq.com)
 * Date: 2016/8/15
 * Time: 9:48
 */

namespace Api\Controller;


class InformationController extends ApiController
{
	/**
	 * 便民信息列表
	 */
	public function informations(){
		$informations = D('information')->order('add_time desc')->select();
		foreach ($informations as &$item){
			$item['thumb'] = D('picture')->Where('id='.$item['thumb'])->getField('path');
//			DUMP
		}
		$informations ? response(1,$informations) : response(-2);
	}

	/**
	 * 便民信息详情
	 */
		public function informationDetail(){
		$id = I('post.id');
		$info = D('information') -> Where('id = '.$id) -> find();
		$info['content'] = stripslashes($info['content']);
		if(!$info)
			response(-2,'','便民信息不存在');
		D('information')->where('id='.$id)->setInc('hits',1);
		$info['thumb'] = D('picture')->Where('id='.$info['thumb'])->getField('path');
		response(1,$info,'便民信息详情获取成功');
	}
}